package org.aplombh.java.utils;

import java.util.Random;

/**
 * Common random number generation
 */
public class DataUtils {

    private static final Random random = new Random();

    /**
     * generates a random int data
     * @param leftMargin min number
     * @param rightMargin max number
     * @return return the random int data
     */
    public static int getInt(int leftMargin, int rightMargin ) {
        return random.ints(1,leftMargin,rightMargin).toArray()[1];
    }

    /**
     * generates a random int data
     * @return return the random int data
     */
    public static int getInt() {
        return random.nextInt();
    }
    /**
     * generates a random int array
     * @param len length of the int array
     * @param leftMargin min number of the int array
     * @param rightMargin max number of the int array
     * @return return the random int array
     */
    public static int[] getInts(int len,int leftMargin, int rightMargin ) {
        return random.ints(len, leftMargin, rightMargin).toArray();
    }
    /**
     * generates a random int array
     * @param len length of the int array
     * @param rightMargin max number of the int array
     * @return return the random int array
     */
    public static int[] getInts(int len,int rightMargin ) {
        return random.ints(len, 0, rightMargin).toArray();
    }

    /**
     * generates a random int array
     * @param len length of the int array
     * @return return the random int array
     */
    public static int[] getInts(int len) {
        return random.ints(len).toArray();
    }


    /**
     * generates a random double array
     * @param len length of the double array
     * @param leftMargin min number of the double array
     * @param rightMargin max number of the double array
     * @return return the random double array
     */
    public static double[] getDoubles(int len,int leftMargin, int rightMargin ) {
        return random.doubles(len, leftMargin, rightMargin).toArray();
    }

    /**
     * generates a random double array
     * @param len length of the double array
     * @param rightMargin max number of the double array
     * @return return the random double array
     */
    public static double[] getDoubles( int len,int rightMargin) {
        return random.doubles(len, 0, rightMargin).toArray();
    }

    /**
     * generates a random double array
     * @param len length of the double array
     * @return return the random double array
     */
    public static double[] getDoubles(int len) {
        return random.doubles(len).toArray();
    }

}
